/**
 * 
 */
package com.lehecai.core.lottery.ticket;

import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import com.lehecai.core.YesNoStatus;
import com.lehecai.core.api.AbstractApiResultBean;
import com.lehecai.core.lottery.LimitNumberType;
import com.lehecai.core.lottery.LotteryType;
import com.lehecai.core.lottery.PlayType;
import com.lehecai.core.util.CoreDateUtils;


/**
 * 投注限号
 * @author He Wang
 *
 */
public class BettingLimitNumber extends AbstractApiResultBean {
	
	public static final String QUERY_ID = "id";
	public static final String QUERY_LOTTERY_TYPE = "lottery_type";
	public static final String QUERY_PLAY_TYPE = "play_type";
	public static final String QUERY_STATUS = "status";

	public static final String SET_LOTTERY_TYPE = "lottery_type";
	public static final String SET_PLAY_TYPE = "play_type";
	public static final String SET_LIMIT_TYPE = "limit_type";
	public static final String SET_LIMIT_VALUE = "limit_value";
	public static final String SET_VALUE = "value";
	public static final String SET_STATUS = "status";
	public static final String SET_REASON = "description";
	
	private Integer id;		                //渠道id
	private LotteryType lotteryType;		//渠道名称
	private PlayType playType;		        //密码
	private YesNoStatus status;	            //默认的回扣率
	private LimitNumberType limitNumberType;//限制类型
	private String limitValue;              //限制类型值
	private String value;                   //所限号码
	private String reason;                  //限号原因
	private Date createdTime;
	private Date updatedTime;
	
	public static BettingLimitNumber convertFromJSONObject(JSONObject object) {
		if (object == null) {
			return null;
		}
		BettingLimitNumber bettingLimitNumber = new BettingLimitNumber();
		
		bettingLimitNumber.id = getInt(object, QUERY_ID);
		bettingLimitNumber.lotteryType = LotteryType.getItem(getInt(object, QUERY_LOTTERY_TYPE));
		bettingLimitNumber.playType = PlayType.getItem(getInt(object, QUERY_PLAY_TYPE));
		bettingLimitNumber.status = YesNoStatus.getItem(getInt(object, QUERY_STATUS));
		bettingLimitNumber.limitNumberType = LimitNumberType.getItem(getInt(object, SET_LIMIT_TYPE));
		bettingLimitNumber.limitValue = getString(object, SET_LIMIT_VALUE);
		bettingLimitNumber.value = getString(object, SET_VALUE);
		bettingLimitNumber.createdTime = CoreDateUtils.parseDate(getString(object, "create_at"), CoreDateUtils.DATETIME);
		bettingLimitNumber.updatedTime = CoreDateUtils.parseDate(getString(object, "update_at"), CoreDateUtils.DATETIME);
		bettingLimitNumber.reason = getString(object, SET_REASON);
		return bettingLimitNumber;
	}
	
	public static List<BettingLimitNumber> convertFromJSONArray(JSONArray array) {
		if (array == null) {
			return null;
		}
		List<BettingLimitNumber> list = new ArrayList<BettingLimitNumber>();
		for (Iterator<?> iterator = array.iterator(); iterator.hasNext();) {
			JSONObject object = (JSONObject) iterator.next();
			list.add(convertFromJSONObject(object));
		}
		return list;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Integer getId() {
		return id;
	}

	public void setLotteryType(LotteryType lotteryType) {
		this.lotteryType = lotteryType;
	}

	public LotteryType getLotteryType() {
		return lotteryType;
	}

	public void setPlayType(PlayType playType) {
		this.playType = playType;
	}

	public PlayType getPlayType() {
		return playType;
	}

	public void setStatus(YesNoStatus status) {
		this.status = status;
	}

	public YesNoStatus getStatus() {
		return status;
	}

	public void setLimitNumberType(LimitNumberType limitNumberType) {
		this.limitNumberType = limitNumberType;
	}

	public LimitNumberType getLimitNumberType() {
		return limitNumberType;
	}

	public void setLimitValue(String limitValue) {
		this.limitValue = limitValue;
	}

	public String getLimitValue() {
		return limitValue;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public String getValue() {
		return value;
	}

	public void setCreatedTime(Date createdTime) {
		this.createdTime = createdTime;
	}

	public Date getCreatedTime() {
		return createdTime;
	}

	public void setUpdatedTime(Date updatedTime) {
		this.updatedTime = updatedTime;
	}

	public Date getUpdatedTime() {
		return updatedTime;
	}

	public String getReason() {
		return reason;
	}

	public void setReason(String reason) {
		this.reason = reason;
	}
}
